package model

import (
	"strings"
	"time"
)

type SysApi struct {
	ApiId     int64     `json:"api_id" gorm:"primaryKey;autoIncrement;comment:主键编码"` //apiId
	Handle    string    `json:"handle" gorm:"size:128;comment:handle"`               //Handle
	Title     string    `json:"title" gorm:"size:128;comment:标题"`                    //api名称
	Path      string    `json:"path" gorm:"size:128;comment:地址"`                     //api路径
	Method    string    `json:"method" gorm:"size:16;comment:请求方法"`                  //请求方法
	Tags      string    `json:"tags" gorm:"size:128;comment:标签"`                     //标签
	Key       string    `json:"key" gorm:"size:32;comment:md5"`                      //md5
	CreatedAt time.Time `json:"created_at"`
}

func (s *SysApi) TableName() string {
	return "sys_api"
}

func (s *SysApi) GetTags() []string {
	return strings.Split(s.Tags, ",")
}
